<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
    >
      <el-form-item label="ppt模板名称" prop="pptName">
        <el-input
          v-model="queryParams.pptName"
          placeholder="请输入ppt模板名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>


    <el-table v-loading="loading" :data="list">
      <el-table-column label="ppt名称" align="center" prop="userPptName" />
      <el-table-column label="ppt链接" align="center" prop="pptLinkUrl" />
      <el-table-column label="创建时间" align="center" prop="createdAt" />
      <el-table-column label="ppt模版名称" align="center" prop="pptName" />
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import {
  userPPtList,
} from "@/api/ppt/pptComponent";

export default {
  name: "PPTCategory",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 菜单表格树数据
      list: [],
      // 菜单树选项
      cateOptions: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 是否展开，默认全部折叠
      isExpandAll: false,
      // 重新渲染表格状态
      refreshTable: true,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        pptName: [
          { required: true, message: "模板名称不能为空", trigger: "blur" },
        ],
        cateId: [
          { required: true, message: "模板分类不能为空", trigger: "change" },
        ],
      },
      total: 0,
    };
  },
  created() {
    this.getList();
    this.getTreeselect();
  },
  methods: {
    /** 查询菜单列表 */
    getList() {
      this.loading = true;
      userPPtList(this.queryParams).then((response) => {
        this.list = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },

    // 表单重置
    reset() {
      this.form = {
        isStatus: 1,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

  },
};
</script>
